package cn.house.interce;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

import cn.house.entity.User;

public class UserInterception extends AbstractInterceptor{

	/**
	 * 
	 */
	private static final long serialVersionUID = 3947809802021466473L;

	@Override
	public String intercept(ActionInvocation paramActionInvocation) throws Exception {
		
		System.out.println("进入拦截");
		
		User user = (User) ActionContext.getContext().getSession().get("userSession");
		if(user == null){
			ServletActionContext.getRequest().setAttribute("message", "请先登录");
			return "login";
		}
		
		
		String res = paramActionInvocation.invoke();
		
		System.out.println("离开拦截器");
		return res;
	}
}
